let app = getApp();
Page({
  data: {
    winHeight: 500,
    currentTab: 0,
    moment: [],
    capitalInfo:{
      "amount": 0,
      "accountCashAmount": 0,
      "balance": 0,
    },
    colorList: []
  },
  onLoad(options) {
    options.flag === "wine" ? this.setData({
      currentTab: 0
    }) : this.setData({
      currentTab: 1
    });
    wx.getSystemInfo({
      success: (res) => {
        this.setData({
          winHeight: res.windowHeight
        });
      }
    });
    this.listProductAccount();
    this.capitalInfo();
    app.checkLogin();
  },
  capitalInfo(){
    wx.showLoading({
      title: '正在加载...',
    })
    app.post("findAccountInfo").then((res) => {
      wx.hideNavigationBarLoading();
      wx.hideLoading();
      let turnover = res.data.turnover,newArr=[];
      this.setData({
        capitalInfo:{
          "amount": res.data.amount/100,
          "accountCashAmount": res.data.accountCashAmount / 100,
          "balance": res.data.balance / 100,
        },
        colorList: res.data.turnover
      })
    }).catch((e) => {
      wx.hideLoading();
      wx.hideNavigationBarLoading();
      app.toast("网络或服务器错误～");
    })
  },
  jumpMineWine(event) {
    var thisId = event.currentTarget.id,url = '';
    if (thisId == "Deposit") {
      url = "/pages/mine/mine_Physical_money/Phy_withdraw_detail/Phy_withdraw_detail?balance=" + this.data.capitalInfo.balance +"";
    } else if (thisId == "moenyDetail") {
      url = "/pages/mine/mine_Physical_money/Phy_money_detail/Phy_money_detail";
    } else if (thisId == "haveWithdraw") {
      url = "/pages/mine/mine_Physical_money/Phy_wdeposit_detail/Phy_wdeposit_detail";
    } else if (thisId == "mayWithdraw") {
      url = "/pages/mine/mine_Physical_money/Phy_withdraw_detail/Phy_withdraw_detail?balance=" + this.data.capitalInfo.balance+"";
    }
    wx.navigateTo({
      url: url
    });
  },
  //跳转页面
  jumpMoeny() {
    wx.redirectTo({
      url: '/pages/mine/mine_Physical_accounts/Phy_accounts'
    });
  },
  //跳转页面
  jumpMoeny(event) {
    var thisId = event.currentTarget.id,
      url = '';
    if (thisId == "button") {
      app.toast("正在开发中...")
      // url = "/pages/mine/mine_Physical_accounts/Phy_buyBack/Phy_buyBack";
    }  else {
      url = "/pages/mine/mine_Physical_money/Phy_money";
    }
    wx.navigateTo({
      url: url
    });
  },
  jumpItem(event) {
    var url = "/pages/mine/mine_Physical_accounts/Phy_wine/Phy_wine";
    wx.navigateTo({
      url: url
    });
  },
  listProductAccount() {
    app.post("listProducAccount").then((res) => {
      wx.hideNavigationBarLoading();
      this.setData({
        // moment: res.data
      })
    }).catch((e) => {
      wx.hideNavigationBarLoading();
      app.toast("网络或服务器错误～");
    })
  },
  bindChange: function(e) {
    this.setData({
      currentTab: e.detail.current
    });
  },
  swichNav(e) {
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      this.setData({
        currentTab: e.target.dataset.current
      })
    }
  }
})